package com.hodgepodge.sso.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * title TestController
 * projectName colorful-blog
 * desc 测试控制器
 *
 * @author jiangjian
 * @date 2020/9/20 14:38
 */
@RestController
public class TestController {

    @RequestMapping("login")
    @SentinelResource(value = "hello", blockHandler = "blockHandler")
    public String hello() {
        return "{\"code\": 200, \"message\": \"成功\", \"data\": {\"username\": \"Hello World\"}}";
    }

    public String blockHandler(BlockException ex) {
        return "被限流降级了";
    }

    public String fallback() {
        return "出现位置异常";
    }

}
